<?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;

class Controller extends BaseController
{
    protected $db;

    /**
     * 接口返回格式
     */
    public function toJson($code = 0, $msg = '', $data = [], $total = 0)
    {
        if (!$msg) $msg = 'success';
        $json = [
            'code' => $code,
            'msg' => $msg ? $msg : '成功',
            'data' => $data,
            'total' => $total,
        ];
        return $json;
    }
}
